{% extends 'bookcopy_base.html' %}

{% load cancel_or_request %}

{% block header %}{% if for_whom %} {{ for_whom }} {% else %} Book reservation {% endif %} {% endblock %}

{% block go_up %}
    <div class="goUpWrapper">
        <a href="up/">Up</a>
    </div>
{% endblock %}

{% block form %}
    <h3 id="rr">Reserve/Rent</h3>
    
    {% if reserved.msg %}
        <p class='positive_message'>
            {{ reserved.msg }}.
        </p>
<!--
        {% if perms.baseapp.view_others_profile %}
        <div class="inner_menu">
          <ul>
            <li><a href={% url user_one reader_id %}>Go to profile</a></li>
          </ul>
        </div>
        {% endif %}
-->
        {% if reserved.reservation %}
            {% cancel_or_request_form %}

            {% if display_tips %}
                <div class="tip">
                    <ul>
                        <li>
                            If you clicked reserve by mistake you can cancel your reservation by clicking Cancel
                        </li><li>
                            By clicking "Send me" you request shipment with internal post. You don't need to send any emails to librarians, they will be notified of your request (and maybe someone will even really mail it to you:)
                        </li>
                    </ul>
                </div>
            {% endif %}
        {% endif %}
        {% comment %}
        --------{{reserved.copy_id}}--------
        {% endcomment %}
    {% else %}
        {% if reserved.error %}
           <p class='negative_message'> 
                {{ reserved.error }}
            </p>
        {% endif %}
        <div class='content_form' style='margin-top: 1em'>
            <form action='.' method='post' name="Freserve">
                <table>
                    <tr>
                        <td>From: </td>
                        <td><input type='text' maxlength='10' class="datepicker" name='from' value='{{ reserve_from }}' onClick='showKal(this)'></td>
                        {% if perms.baseapp.add_rental %}
                            <td>(Ignored if renting. You always rent from today)</td>
                        {% endif %}
                    </tr>
                    <tr>
                        <td>To: </td>
                        <td><input type='text' maxlength='10' class="datepicker" name='to' value='{{ reserve_to }}' onClick='showKal(this)'></td>
                    </tr>
                    <tr>
                        <td>User</td>
                        <td>
                            <input type='text' 
                                   maxlength='50' 
                                   name='user' 
                                   value='{% if for_whom %}{{ for_whom }}{% else %}{{ user.last_name }}, {{ user.first_name }}{% endif %}'
                                   {% comment %} {% if disabled %} disabled='disabled' {% endif %} {% endcomment %}
                                   disabled='disabled' 
                                   >
                        </td>
                    </tr>
                    <tr>
                        <td></td>
                        <td><input type='submit' name='reserve_button' value='Reserve' {% if not can_reserve %} disabled {% endif %}  ></td>
                        <td></td>
                    </tr>
                    {% if perms.baseapp.add_rental %}
                        <tr>
                            <td></td>
                            <td><input type='submit' name='rent_button' value='Rent' {% if not rental_possible %} disabled {% endif %} ></td>
                            <td></td>
                            {% if display_tips %}
                            <div class="tip">
                                <ol>
                                    <li>
                                        When renting "From:" field is ignored - books are always rented from today.
                                    </li>
                                    <li>
                                        When renting "To:" field means until when you rent the book.
                                    </li>
                                </ol>
                            </div>
                            {% endif %}
                    {% endif %}
                        </tr>
                </table>
            </form>
            <script type="text/javascript">
                document.Freserve.nothing.focus();
            </script>
        </div>
    {% endif %}

{% endblock %}
